package com.smartstate.dataManagement.util;

public class QuartzUtils {

    /**
     * 根据采集周期设置定时任务的采集周期
     *
     * @return
     */
    public static String cycle(String cycle) {
        switch (cycle) {
            case "1s":
                cycle = "0/1 * * * * ?";
                break;
            case "10s":
                cycle = "0/10 * * * * ?";
                break;
            case "1min":
                cycle = "0 0/1 * * * ?";
                break;
            case "10min":
                cycle = "0 0/10 * * * ?";
                break;
        }
        return cycle;
    }

    /**
     * 根据设备类型来设置定时任务调用的方法
     *
     * @param type     设备类型
     * @param id 设备id
     * @return
     */
    public static String type(String id, int type) {
        String invokeTarget = "";
        switch (type) {
            case 1:  //工业看板
                invokeTarget = "quartz.storting('" + id + "')";
                break;
            case 2:  //电表
                invokeTarget = "quartz.electricMeter('" + id + "')";
                break;
            case 3:  //水表
                invokeTarget = "quartz.WaterMeter('" + id + "')";
                break;
            case 4:  //蒸汽表
                invokeTarget = "quartz.getSteam('" + id + "')";
                break;
            case 5:  //天然气表
                invokeTarget = "quartz.getGas('" + id + "')";
                break;
            case 6:  //天然气表
                invokeTarget = "quartz.dehumidifier('" + id + "')";
                break;
            default:
                invokeTarget = "quartz.defaultMethod('" + id + "')";
                break;
        }
        return invokeTarget;
    }
}
